#ifndef QPageManager_H
#define QPageManager_H

#include <QObject>
#include "sharedlibglobal.h"


#include <QList>

class QXmlStreamReader;

namespace SHAREDLIB
{
    class QPageInfo;

    class SHAREDLIB_EXPORT QPageManager : public QObject
    {
        Q_OBJECT
    public:
        explicit QPageManager(QObject *parent = 0);
        ~QPageManager();

        void        addPage(QPageInfo* info);
        int         insertPage(QPageInfo* info,int index);
        void        removeAt(int index);
        void        removePage(const QString &type,const QString& name);
        void        removePage(QPageInfo *info);

        QPageInfo*  getPage(int index);
        QPageInfo*  getPage(const QString &type,const QString& name);
        QList<QPageInfo*>   getPages(const QString& type);
        int         pageCount();

        void        setCurrentPage(const QString &type,const QString &name);
        QPageInfo*  getCurrentPage();

        void        load(const QString &projectPath);
        void        save(const QString &projectPath);
        void        clear();
        void        refreshForm();
    protected:
        bool        readPage(QXmlStreamReader* r,QString &name,QString &type);
    signals:
        void    currentFormChanged();
        void    refresh();
        void    addPageSignal(SHAREDLIB::QPageInfo* info);
        void    delPageSignal(SHAREDLIB::QPageInfo* info);
    protected:
        QList<QPageInfo*>     m_pages;
        QPageInfo*            m_current;
    };

}

#endif // QPageManager_H
